package org.bear.bundle.framework.controller;

import it.sauronsoftware.cron4j.Scheduler;

import java.util.Map;

public class AgentPluginStatusTask {

	Scheduler scheduler;
	String taskID;

	public void sendPluginStatus(String pattern, String brokerUrl,
			String username, String password, Map<String, Object> pluginMap) {

		scheduler = new Scheduler();
		taskID = scheduler.schedule(pattern, new PluginTask(brokerUrl,
				username, password, pluginMap));
		scheduler.start();
	}

	public void stop() {
		scheduler.deschedule(taskID);
		scheduler.stop();
		Runtime.getRuntime().gc();
	}

}
